const db = require('./db')

//插入的数据对象
const data = [
    {id: 0, icon: '/images/subjectIcons1.png', title: "JavaEE"},
    {id: 1, icon: '/images/subjectIcons2.png', title: "全栈UI设计"},
    {id: 2, icon: '/images/subjectIcons3.png', title: "H5前端"},
    {id: 3, icon: '/images/subjectIcons4.png', title: "Python"},
    {id: 4, icon: '/images/subjectIcons5.png', title: "iOS"},
    {id: 5, icon: '/images/subjectIcons6.png', title: "大数据"},
    {id: 6, icon: '/images/subjectIcons7.png', title: "C++"}
]
//循环插入数据库
data.forEach( item => {
    let sql = `insert into subject values (${item.id}, '${item.icon}', '${item.title}')`

    //插入数据
    db.query(sql, (err, result) => {
        if(err) throw err

        console.log(result)
    })
})